<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="林镭特">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form action="#">
        <input type="text" name="username" placeholder="账号"> <br>
        <input class="p1" type="password" name="password" placeholder="密码"> <br>
        <input class="p2" type="password" name="password2" placeholder="密码重复">
        <button type="button">注册</button>
    </form>
    <script src="https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js"></script>
    <script src="./layer/layer.js"></script>
<script>

    $('button').click(()=>{
        if($('.p1').val() != $('.p2').val()){    
            layer.msg('密码不一致！');
            return ;
        }
        var param = $('form').serialize();
        $.post('/register', param, data=>{
            if (data.error == 0) {
                location.href = './login.html'
            } else {
                layer.msg(data.txt);
            }
        });
    });
</script>
</body>
</html>